Skip to content

Conversation

@byteZorvin
Copy link
Member

Pull Request type

Please add the labels corresponding to the type of changes your PR introduces:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no API changes)
  • Build-related changes
  • Documentation content changes
  • Testing
  • Other (please describe):

What is the current behavior?

Resolves: #NA

What is the new behavior?

Does this introduce a breaking change?

Other information

@byteZorvin byteZorvin marked this pull request as draft October 28, 2025 05:45
@byteZorvin byteZorvin marked this pull request as ready for review October 28, 2025 06:04
Copy link
Contributor

@prkpndy prkpndy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gg. the logic looks good! have some questions regarding the implementation

inner: S,
min_confirmations: u64,
latest_block: Arc<AtomicU64>,
_update_task: tokio::task::JoinHandle<()>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we remove it if not used?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's used. it keeps the latest block updating task in memory so that it's not dropped. we should add a comment @byteZorvin


/// Minimum settlement blocks for L1 sync.
/// This is the minimum number of blocks that must be settled on L1 before the node can sync/process the messages.
#[clap(env = "MADARA_MIN_SETTLEMENT_BLOCKS", long, default_value = "10")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can we give it a better name if possible? something like MADARA_MIN_SETTLED_BLOCKS_FOR_MESG_PROCESSING (this is too long but something along these lines)

Comment on lines +95 to +96
/// making the stream implementation much simpler. It's generic and works with any
/// settlement layer provider.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if it can be used with any settlement client, why are we writing it again for starknet client below?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed, we should have one fileter and make it work for both

Comment on lines +165 to +171
pub struct ConfirmationDepthFilteredStream<S, P> {
inner: S,
min_confirmations: u64,
latest_block: Arc<AtomicU64>,
_update_task: tokio::task::JoinHandle<()>,
_phantom: std::marker::PhantomData<fn() -> P>,
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we also have it in ethereum settlement client? why is it duplicated?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we create a single struct and a trait and implement that for different clients (if we need to)?

Copy link
Contributor

@apoorvsadana apoorvsadana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea of the filter is good. However, I am unsure if it works as intended.

Comment on lines +150 to +167
Poll::Ready(Some(Ok(event))) => {
// Check if this event meets the confirmation depth requirement
let latest = self.latest_block.load(Ordering::Relaxed);
let threshold = latest.saturating_sub(self.min_confirmations);

if event.l1_block_number <= threshold {
return Poll::Ready(Some(Ok(event)));
}

// Event doesn't have enough confirmations yet, skip it and continue polling
tracing::debug!(
"Skipping event at block {} (needs {} confirmations, latest L1 block: {})",
event.l1_block_number,
self.min_confirmations,
latest
);
// Continue the loop to get the next event
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we sure this works? seeems to me that if the depth isn't met then we will not do anything and that event will never come again?

Comment on lines +95 to +96
/// making the stream implementation much simpler. It's generic and works with any
/// settlement layer provider.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed, we should have one fileter and make it work for both

inner: S,
min_confirmations: u64,
latest_block: Arc<AtomicU64>,
_update_task: tokio::task::JoinHandle<()>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's used. it keeps the latest block updating task in memory so that it's not dropped. we should add a comment @byteZorvin

/// This uses a background task to periodically update the latest block number,
/// making the stream implementation much simpler. It's generic and works with any
/// settlement layer provider.
pub struct ConfirmationDepthFilteredStream<S> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how can we write a test case for this?

pub settlement_layer: MadaraSettlementLayer,

/// Minimum settlement blocks for L1 sync.
/// This is the minimum number of blocks that must be settled on L1 before the node can sync/process the messages.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// This is the minimum number of blocks that must be settled on L1 before the node can sync/process the messages.
/// Minimum number of block confirmations an event must have before it can be processed from the settlement layer

@byteZorvin byteZorvin marked this pull request as draft November 22, 2025 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

5 participants